package com.itheima.springbootrequestresponse.controller;

import com.itheima.springbootrequestresponse.pojo.User;
import com.itheima.springbootrequestresponse.service.UserService;
import com.itheima.springbootrequestresponse.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * UserController
 *
 * @author liliudong
 * @version 1.0
 * @description
 * @date 2023/7/7 20:00
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据用户名查询用户信息
     *
     * @param username
     * @return
     */
    @RequestMapping("/user/{username}")
    public Result getByUserName(@PathVariable String username) {
        User user = userService.getByUserName(username);
        return Result.success(user);
    }
}
